Skip to content

Fix role binding and settings in the SOP orchestrator - #1154

Merged
Robert0622 merged 9 commits into
mainfrom
codex/fix-sop-orchestrator-role-settings
Nov 21, 2026
Merged

Robert0622 merged 9 commits into
mainfrom
codex/fix-sop-orchestrator-role-settings

Conversation

@Robert0622

Copy link
Copy Markdown
Collaborator

Changes

  • Refresh the role catalog for the SOP's project before orchestration. When a new role is needed, let the user review and save it in the existing role wizard before binding it to a node.
  • Resume orchestration with the saved conversation transcript so the follow-up turn uses the newly saved role. If a generated graph still references an unavailable role, restore the canvas and identify the affected nodes.
  • Reveal the node inspector when a node is selected while AI chat is open. Preserve the conversation and link the inspector to the bound role and its verification settings.
  • Keep the feedback control clear of the assistant's send button.

Verification

  • Passed the Go web package and the targeted browser-logic regression tests.
  • Verified two live CodeBuddy DeepSeek V4.1 Flash turns in Chromium. Created a project role, bound it to a generated SOP, saved the workflow, and checked inspector switching, the role deep link, reload, browser back, and the verification tab.
  • Ran the saved role with DeepSeek V4.1 Flash in an isolated instance. The role succeeded, the run reached the manual gate, and the SOP succeeded after approval.

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

初审 #1154(head 2b99578,merge-base d58a85a)。

审查范围:本 PR 全部 10 个文件的改动,重点是 web/orchestrate.js 中按存档会话续接编排、编排前刷新项目角色、agents_save 角色草稿交由角色向导确认、角色不可用时恢复画布,以及 app.js/agents.js/flows.js 中角色深链、向导关闭/路由同步、选中节点时收起 AI 面板等。

验证:在隔离环境构建 chatbot 后 go test ./web/ 通过;orchestrate-ai/orchestrate-build/flow-designer/flows-editor/assets-agents/views/app-shell 等 8 个 webtest 文件 34 个用例在 head 全部通过;CI 16 项全部成功。另编写 jsdom 临时用例在 head 与合并基线上对比复现。

发现 1 个 P3 问题(详见行内评论):存档会话被删除后,GET /api/assistant/sessions/:id 404 使后续每一轮都报「对话不存在」,且缓存的 sessionId 不会被清除;基线在同一场景下可继续编排。

未验证范围:未能用真实模型后端跑多轮编排(无凭据);未跑完整 webtest 全量与真实浏览器交互检查(依赖 CI browser 任务结果)。以上不代表代码没有其他缺陷。

Comment thread web/orchestrate.js Resolved
@Robert0622

Copy link
Copy Markdown
Collaborator Author

用 Chromium 和 CodeBuddy iOA 的 DeepSeek V4.1 Flash 复测了编排后在原会话追加角色和审批的场景。

  • 基线 d58a85a 首轮生成草稿成功,原会话第二轮返回 HTTP 409「共享会话已更新,请重新打开后发送」。
  • Fix role binding and settings in the SOP orchestrator #1154 的合并预览 e34ab530 第二轮返回 200,并给出了可确认的角色草稿。确认角色后的第三轮返回了正确的 SOP 草稿,画布应用时出现 Cannot read properties of undefined (reading 'x')。
  • 后续修复 fix(sop): keep streamed node positions when applying edits #1162 保留了流式放置的节点坐标。同一场景三轮都返回 200。原 SOP 保存为草稿修订 2,重新打开后核对了四个节点和三条成功连线。

@Robert0622

Copy link
Copy Markdown
Collaborator Author

画布修复已直接追加到本 PR,提交为 c9580a8,与此前 CodeBuddy iOA + DeepSeek V4.1 Flash 浏览器实测的提交一致。同一会话三轮均返回 HTTP 200,创建并绑定新角色、追加最终人工审核后,重新打开已保存的 SOP,确认四个节点和三条连线完整。

GitHub 已将 #1162 标记为合并到本 PR 的分支。后续评审集中在 #1154。

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审 #1154(head 8d2ed0b,merge-base d58a85a)。

复审范围:上次 Review(2b99578)之后新增的 2 个提交 c9580a8(AI 编辑完成时保留流式放置的节点坐标、清空待放置队列)和 8d2ed0b(会话进程已退出后发送 EOF 不再报 file already closed),以及历史 P3 问题。

历史问题:

  • [P3] 存档会话不存在时编排助手后续每一轮都失败:STILL_PRESENT。head 上同一 jsdom 用例三轮 chat 调用次数仍为 1/1/1、日志「对话不存在」、缓存 sessionId 未清除;基线为 1/2/3。详见原线程。

新提交审查与验证:

  • c9580a8:用 node --test 补跑边界用例(流式节点被最终草稿删掉、队列中尚未放置的节点、最终草稿新增节点),结果节点全部有坐标、无重复 id、被删节点及其连线未残留,未发现新问题。
  • 8d2ed0b:只在 EOF 分支把 os.ErrClosed 视为成功,写数据分支和其他错误不受影响;新测试 TestConversationProcessEOFAfterExit 在 head 通过(-count=3),把同一测试放到基线上失败(close |1: file already closed),说明修复有效。
  • 构建与测试(head):build-chatbot、go build ./...、go vet ./internal/runtime/、go test ./web/ 通过;webtest 全量 218/218 通过。go test ./internal/runtime/ 在本环境有 10 个 Docker/Chromium/bwrap 相关用例失败,基线 d58a85a 上失败的是同样 10 个,属于环境差异,与本 PR 无关。

未验证范围:未用真实模型后端和真实浏览器跑多轮编排(无凭据);发布前复查 CI,当前 head 的检查全部成功。以上不代表代码没有其他缺陷。

crispinhu27
crispinhu27 previously approved these changes Nov 21, 2026

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审结论:APPROVE(head eace3300,base main@edc27c0)

历史问题

  • [P3] 存档会话不存在时编排助手后续每一轮都失败:FIXED。合并 #991 后原路径已移除,在新的 SopDesigner 上用等价触发复测,删除会话后后续轮次都能成功,详见原线程。

本次审查范围

  • 7103d89(合并 main):冲突集中在 web/orchestrate.js、web/index.html、web/app/flow-canvas.css、webtest/tests/orchestrate-build.test.mjs,以及被删除的 web/orchestrate_models_test.js。
    • 解决方式是采用主线的 iframe 桥接,同时保留本 PR 的 isCurrentAIBuild、角色校验和编排前刷新角色等逻辑。
    • 合并中新增了几处:SopDesigner 在 404 时重新开始会话;agents_save 角色草稿的识别和后端放行(vetSOPDesignerReply/sopDesignerDrafts);「配置并创建角色」按钮。
    • app.js/agents.js/flows.js/conversation_process.go 中本 PR 自身的改动与上一版逐行一致。
  • eace330:修正了 abortAIBuild 里先判断 isCurrentAIBuild 再递增 token 的顺序,否则中断后画布不会恢复。orchestrate-ai 用例也改为走 iframe 消息桥。

已执行的验证(隔离沙箱用户,不接触任何凭据)

  • bash scripts/build-chatbot.sh:vitest 464/464 通过(base 463/463),native-chat 构建成功。
  • go build ./...、go vet(httpapi/runtime/web)、go test ./web/ 通过。go test ./internal/httpapi/ -run "SOP|Draft|Proposal" 通过,TestConversationProcess* 通过(EOF 用例 -count=3)。
  • webtest 全量 node --test:head 221/221 通过,base 219/219 通过。
  • GitHub 检查:core、browser、platform-required、e2e-required 等 16 项全部通过。

未覆盖:没有用真实模型后端和真实浏览器跑多轮编排(无凭据),这部分依赖 CI 的 browser/e2e。还有两处只读代码发现的非阻塞点,没有复现:agents_save 草稿缺 name 时摘要会显示 undefined;生成刚结束、读取会话前那一瞬间会话被删时,这一轮的草稿会被丢弃。

@Robert0622
Robert0622 dismissed crispinhu27’s stale review November 21, 2026 09:49

The merge-base changed after approval.

crispinhu27
crispinhu27 previously approved these changes Nov 21, 2026

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

重新批准:APPROVE(head eace3300 未变,base main@42541ef)

上一条 APPROVE(6004470554)因为合并基线变化被自动 dismiss(main 合入了 #1080)。本 head 没有变化,所以这次只按新基线重新核对了一遍:

  • git merge-tree 和 main@42541ef 合并没有冲突。主线这次的改动(#1080)与本 PR 只在 web/index.html 有交集,主线加的是定时任务超时输入框,本 PR 改的是脚本 cache-bust 版本号,两处互不影响。
  • 在本地合并树上(只在本地,未推送):go build ./...、go vet ./internal/httpapi/ ./web/ 通过。go test ./web/ 通过,go test ./internal/httpapi/ -run "SOP|Draft|Proposal|Schedul|Wait|Timeout" 通过。webtest 全量 221/221 通过。

审查结论和历史问题([P3] FIXED)与 6004470554 相同。

@Robert0622
Robert0622 dismissed crispinhu27’s stale review November 21, 2026 09:57

The merge-base changed after approval.

@crispinhu27

Copy link
Copy Markdown
Collaborator

Review status note (head eace330, automated CR)

The two APPROVE reviews on this head (6004495915 and the one before it) were auto-dismissed within seconds with "The merge-base changed after approval." GitHub still records this PR's base as d58a85a, but the real merge-base with main is edc27c0 and main is now at 42541ef (#1080). A third APPROVE on the same head would most likely be dismissed again, so I'm not posting another one.

This run re-checked the code you'd get from merging main:

  • eace330 merged with main 42541ef locally with no conflicts. fix(schedule): bound AI task runs and wait for SOP outcomes #1080 and this PR only both touch web/index.html, in different hunks.
  • In an isolated sandbox with synthetic data: go build ./... and go vet passed, chatbot vitest passed 464/464, and webtest passed 221/221.
  • go test ./... had 15 failures. main 42541ef fails the exact same 15 in the same environment (Docker, Chromium, bwrap, and git identity aren't available there), so none of them come from this PR.
  • CI on eace330: 16/16 success.

To get the approval to stick, please push a commit that refreshes the base, for example merging the latest main. The next scheduled review will re-check the new head and approve if nothing changed.

crispinhu27
crispinhu27 previously approved these changes Nov 21, 2026

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审结论:APPROVE(head 58ae2e8,PR base main@7dcf3fc,另与最新 main@1584230 做了合并验证)

本次审查范围

  • 上次审查过的是 eace330。新提交 58ae2e8 只是把 main 合并进来(7dcf3fc,带入 #628、#1010、#1164)。
  • 唯一冲突在 internal/runtime/conversation_process.go:本 PR 之前加的 EOF/os.ErrClosed 处理,main 通过 #1164 合入了等价实现。作者解决冲突时采用了 main 的版本,结果和 main 完全一致,没有丢失或重复。
  • 对比本 PR 相对 base 的净改动:git diff edc27c0 eace330 和 git diff 7dcf3fc 58ae2e8 的增删行完全相同,只差上面那 4 行(已进 main)。业务代码没有新改动,之前审查的结论仍然成立。
  • 审查期间 main 前进到 1584230(#1180)。它和本 PR 都改了 web/app.js、web/index.html、conversation_process_test.go,但改的是不同代码块(main 去掉侧栏折叠按钮并改了语言切换;本 PR 改角色刷新、角色向导关闭和脚本版本号)。git merge-tree 显示没有冲突。

验证(PR 代码在无凭据的隔离用户下运行,只用合成数据)

  • 58ae2e8、main@7dcf3fc、58ae2e8+main@1584230 本地合并树三份分别跑了全量测试,合并树只在本地,未推送:
    • chatbot vitest:464/464、463/463、465/465,vite build 均成功。
    • webtest:221/221、219/219、221/221。
    • go build ./...、go vet ./internal/httpapi/ ./internal/runtime/ ./web/ 三份都通过。
    • go test ./...:三份失败的都是同样 13 个用例,例如 TestDockerSandbox*、TestBrowser*Chromium、TestBwrap*、TestEnvironmentIdentityGit*。原因是本机没有 Docker、Chromium、bwrap 和 git 身份,main 上同样失败,和本 PR 无关。其余 27 个包全部通过。
  • 定向用例:go test -count=3 -run TestConversationProcess ./internal/runtime/ 通过(含 TestConversationProcessEOFAfterExit);-run "SOPDesigner|SopDesigner|Draft" ./internal/httpapi/ ./web/ 通过。
  • CI 在 58ae2e8 上 16 项全部 success。

历史问题

  • [P3] 存档会话不存在时,编排助手后续每一轮都失败:之前已复测为 FIXED(见原线程,线程已 resolve)。本次合并没有动相关代码(SopDesigner 和 404 重开会话逻辑),chatbot 的 sop-designer 测试在新 head 上通过。

以上结论只覆盖上述审查和验证范围,不代表代码没有任何缺陷。

crispinhu27
crispinhu27 previously approved these changes Nov 21, 2026

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated CR — APPROVE(复审 head 245b0d0,merge-base 7dcf3fc)

历史问题

  • [P3] 存档会话不存在时编排助手后续每一轮都失败:此前已在 eace330 复测为 FIXED(见原线程),本次 245b0d0 未触及相关代码,SOP Designer Go 测试(含 sop-designer 相关用例)在当前 head 全部通过,结论不变。

上次审查(58ae2e8)→ 本次新增变更(245b0d0)审查范围

仅一个提交,改动两处:

  1. web/orchestrate.js(+1/-1):在 beginAIOrchestratorTurn 中,将 const canvas = aiClone(state.workflow) 从 refreshWorkflowAgents() 调用之前移到之后(角色刷新完成并通过重入检查后再快照画布)。这样 canvas 快照包含了用户在等待角色刷新期间做的节点修改,而不是刷新前的旧状态。逻辑正确,无边界条件问题:refreshWorkflowAgents 失败时函数已经 catch 并继续,重入检查在快照之前已保证 projectId/workflowId 未切换。

  2. webtest/tests/orchestrate-ai.test.mjs(+13):新增用例 starting a turn includes canvas edits made while refreshing roles,模拟角色刷新期间用户推入新节点,断言 begun 返回的 canvas 包含该节点。精确覆盖了上面改动的场景。

验证(head 245b0d0,隔离工作区,无生产凭据)

  • go build ./...:通过(exit 0)
  • Go SOP Designer 测试(TestSOPDesignerConversationIsPrivateAndServerOwned、TestSOPDesignerRequestValidation、TestSOPDesignerCatalogIsReadOnlyAndDraftOnly 等 9 项):全部 PASS(0.357s)
  • 新 webtest starting a turn includes canvas edits made while refreshing roles:PASS(1593ms)

以上结论仅覆盖上述审查和验证范围,不代表代码没有任何缺陷。

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated CR — APPROVE(复审 head d5d54c7,merge-base 7dcf3fc,main 5c343b4)

历史问题

  • [P3] 存档会话 404 后编排助手后续每轮都失败:此前已复测 FIXED;上次 245b0d0 的 APPROVE(review 6005874917)因新推送被 dismiss,本次新提交未触及相关代码,结论不变。

本次新增变更(245b0d0 → d5d54c7,1 个提交)

  • chatbot/src/SopDesigner.jsx:补上 CONFIGURE_ROLE 的 import。在 245b0d0 中第 387 行 onConfigureRole 使用了未导入的 CONFIGURE_ROLE,点击助手草稿上的「配置并创建角色」会抛 ReferenceError。常量值 agentflow-sop-designer-role 与 web/orchestrate.js 监听的 AI_MESSAGES.role 一致,接收端会校验 project/workflow 并打开角色向导。
  • chatbot/tests/sop-designer.test.jsx:新增用例,加载含 agents_save 草稿的会话并点击按钮,断言发往画布的消息内容且不发请求。

验证(隔离工作区,无凭据,Node 22)

  • head:npx vitest run 57 个文件 465/465 通过;npm run build 通过。
  • 基线对照:仅把 SopDesigner.jsx 回退到 245b0d0,新用例失败(ReferenceError: CONFIGURE_ROLE is not defined),head 通过。
  • 合入 main 5c343b4:无冲突;chatbot 467/467 通过、build 通过;webtest 222/222 通过。
  • GitHub CI:当前 head 全部 check 成功。
  • 未执行:本提交仅改前端,本轮未重跑 PR 中其他 Go 文件的测试(上次审查已在 245b0d0 通过,本次未改动)。

以上结论仅覆盖上述审查和验证范围,不代表代码没有任何缺陷。

@Robert0622
Robert0622 merged commit 26ef6e1 into main Nov 21, 2026
16 checks passed
@Robert0622
Robert0622 deleted the codex/fix-sop-orchestrator-role-settings branch November 21, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants